Title Banner

Previous Book Contents Book Index Next

Inside Macintosh: QuickDraw GX Graphics /
Chapter 2 - Geometric Shapes / Using Geometric Shapes


Replacing Geometric Points

The GXSetPoint, GXSetLine, GXSetCurve, GXSetRectangle, GXSetPolygons, and GXSetPaths functions allow you to replace the geometry of an existing shape. The limitation of these functions is that you must replace the entire geometry at once.

QuickDraw GX provides other, more sophisticated, mechanisms for editing shape geometries. The GXSetShapePoints function, which is illustrated in this section, allows you to replace individual geometric points within a shape's geometry. The GXSetPolygonParts, GXSetPathParts, and GXSetShapeParts functions, which are discussed in the next three sections, provide even more ways to edit the geometries of shapes.

The sample function in Listing 2-26 creates a path shape and uses the GXSetShapePoints function to replace two of the path's geometric points.

Listing 2-26 Replacing geometric points

void ReplaceTopTwoControlPoints(void)
{
   gxShape  aPathShape;

   static long twoCurveGeometry[] = {1, /* number of contours */
                                     6, /* number of points */
                                     0x48000000,/* 0100 1000 */
                                     ff(100), ff(150),  /* on */
                                     ff(50),  ff(100),  /* off */
                                     ff(100), ff(50),   /* on */
                                     ff(200), ff(50),   /* on */
                                     ff(250), ff(100),  /* off */
                                     ff(200), ff(150)}; /* on */
                                
                                
   static gxPoint newTopGeometry[] = {ff(140), ff(50), 
                                      ff(160), ff(50)}; 


   aPathShape = GXNewPaths((gxPaths *) twoCurveGeometry);
   GXSetShapeFill(aPathShape, gxOpenFrameFill);
   
   GXSetShapePoints(aPathShape, 3, 2, newTopGeometry);

   GXDrawShape(aPathShape);

   GXDisposeShape(aPathShape);
}
The GXSetShapePoints function takes four parameters:

Therefore, the line of code from the sample function in Listing 2-26

GXSetShapePoints(aPathsShape, 3, 2, newTopGeometry);
replaces the third and fourth geometric point from the original path shape with the two geometric points in the newTopGeometry array.

Figure 2-50 shows the path shape before the geometric points are replaced.

Figure 2-50 A path shape with a flat top

Figure 2-51 shows the path shape after the geometric points are replaced.

Figure 2-51 A path shape with geometric points replaced

For more information about the GXSetShapePoints function, see page 2-142.

The next three sections give examples of functions that allow you even more control in editing the geometric points of a shape's geometry.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
7 JUL 1996




Navigation graphic, see text links

Main | Page One | What's New | Apple Computer, Inc. | Find It | Contact Us | Help